'use strict'

describe 'Controller: MainCtrl', () ->

  # load the controller's module
  beforeEach module 'mymealplanrApp'

  MainCtrl = {}
  scope = {}
  $httpBackend = {}

  # Initialize the controller and a mock scope
  beforeEach inject (_$httpBackend_, $controller, $rootScope) ->
    $httpBackend = _$httpBackend_
    $httpBackend.expectGET('/api/recipe').respond
      recipes :{
        title: 'Sausage Pepper Skillet'
        name: 'Test User',
        scheduled: [new Date(2014, 2, 7)]
        source: 'http://www.yummly.com/recipe/Steak-and-scallops-with-champagne-butter-sauce-344478?columns=5'
      },
      {
        title: 'Lemon Pepper Chicken & Rice'
        name: 'Test User',
        scheduled: [new Date(2014, 3, 7)]
        source: 'http://www.yummly.com/recipe/Pan-Seared-Salmon-with-Avocado-Remoulade-Simply-Recipes-42712?columns=5'
      }
    $httpBackend.expectGET('/api/event').respond
    events {
        title: 'Stuffed Peppers with Tomato Basil Cream Sauce',
        name: 'Test User',
        start: new Date(myDate.year, myDate.month, 1),
      },
      {
        title: 'Steak and Scallops with Champagne-Butter Sauce',
        name: 'Test User',
        start: new Date(myDate.year, myDate.month, 2)
      }
    scope = $rootScope.$new()
    MainCtrl = $controller 'MainCtrl', {
      $scope: scope
    }

  it 'should attach a list of events to the scope', () ->
    expect(scope.events).toBeUndefined()
    $httpBackend.flush()
    expect(scope.events.length).toBe 2
  
